package com.kws.tool.controller;

import com.kws.common.core.domain.R;
import com.kws.tool.service.UploadFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * <b>UploadFileController</b>
 *
 * @description: UploadFileController <br>
 * @date: 2024/11/22 14:20 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "文件上传")
@RestController
public class UploadFileController {
    private static final Logger logger = LoggerFactory.getLogger(UploadFileController.class);

    @Autowired
    private UploadFileService uploadFileService;

    @ApiOperation("上传文件获取文件地址")
    @PostMapping("/uploadFile")
    public R uploadFile(@RequestParam("file") MultipartFile file){
        String fileUrl = uploadFileService.uploadFile(file);
        return R.ok(fileUrl);
    }

}
